Component({
  data:{
    needLeft: false,
    needRight: false,
  },
  properties: {
    options: {
      type: Array,
      value: []
    },
    current: { 
      type: Number,
      value: 0,
      observer(newVal, oldVal){
        const { options } = this.data;
        if (options.length > 5) {
          if (newVal > oldVal && (newVal == 3 || newVal == 4)) {
            this.setData({
              needLeft: true,
              needRight: false,
            })
          }else if(newVal < oldVal && (newVal == options.length - 4 || newVal == 2)){
            this.setData({
              needRight: true,
              needLeft: false
            })
          }
        }
      }
    }
  },
  methods: {
    handleTabbarClick(event) {
      const index = event.currentTarget.dataset.index
      this.setData({
        current: index
      })
      this.triggerEvent('change', {
        current: index
      })
    }
  }
})
